const http = require('http');
const ejs = require('ejs');


http.createServer( (req, res) => {
    res.writeHead(200, {'Content-Type': 'text/html; charset:utf-8'});

    // 渲染模板
        ejs.renderFile('./views/index.ejs', {msg: '你好, EJS!', list:['item1', 'item2', 'item3', 'item4'], isLogin: true}, (err, str) => {
            if (err) {
                console.log(err);
                return ;
            }
            res.end(str);
        })

}).listen(3000, '127.0.0.1', () => {
    console.log('server is running!');
}) 